import 'babel-polyfill'
import 'classlist-polyfill'
import Vue from 'vue'
import axios from './router/axios'
import VueAxios from 'vue-axios'
import App from './App'
import zhLocale from './lang/zh'
import './permission' // 权限
import './error' // 日志
import './cache'//页面缓冲
import router from './router/router'
import store from './store'
import permission from './directive/index'

import L from "leaflet"
// import * as L from 'leaflet';
import 'leaflet/dist/leaflet.css';
// import 'leaflet.pm';
// import 'leaflet.pm/dist/leaflet.pm.csss';


import {loadStyle, downBlobFile} from './util'
import {validatenull} from './util/validate'
import * as urls from '@/config/env'
import {iconfontUrl} from '@/config/env'
import * as filters from './filters' // 全局filter
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './styles/common.scss'
import './styles/theme/current/index.css'
import AvueFormDesign from 'pig-avue-form-design'
import basicContainer from './components/basic-container/main'
// import * as echarts from 'echarts'
import 'echarts';
import VueEcharts from 'vue-echarts'
// 字典数据组件
import DictResolver from '@/components/DictResolver'
// 字典标签组件
import DictTag from '@/components/DictTag'

import PageMain from '@/components/PageMain';
import PageLr from '@/components/PageMain/lr.vue';
import DeleteData from '@/components/DeleteData'
import MyDateRange from '@/components/MyDateRange'
import MyEcharts from '@/components/MyEcharts'
import MyUpload from '@/components/MyUpload'
import FormItem from '@/components/FormItem'
import FormRender from '@/components/FormRender'

import http from '@/assets/js/http.js'
import util from '@/assets/js/util.js'
import verify from '@/assets/js/verify.js'
import icon from '@/assets/js/icon.js'
import moment from 'moment';
import htmlToPdf from "@/assets/js/htmlToPdf";
import Print from 'vue-print-nb'

// 挂载常用全局方法，import 引入
Vue.prototype.validatenull = validatenull
Vue.prototype.downBlobFile = downBlobFile
Vue.prototype.$request = http // 请求方法
Vue.prototype.$util = util // 工具集合
Vue.prototype.$verify = verify // 表单验证
Vue.prototype.$icon = icon // 本地图标
Vue.prototype.$moment = moment;
// Vue.prototype.$L = L;
// leaflet icon
delete L.Icon.Default.prototype._getIconUrl;
L.Icon.Default.mergeOptions({
  iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
  iconUrl: require('leaflet/dist/images/marker-icon.png'),
  shadowUrl: require('leaflet/dist/images/marker-shadow.png'),
});

Vue.config.productionTip = false;
Vue.L = Vue.prototype.$L = L;

DictResolver.install()

// 插件 json 展示
Vue.use(router)
// 表单设计器
Vue.use(AvueFormDesign);
Vue.use(htmlToPdf)
Vue.use(Print);

window.axios = axios
Vue.use(VueAxios, axios)

Vue.use(ElementUI, {
  size: 'small',
  menuType: 'text'
})

// 全局修改默认配置，点击空白处不能关闭弹窗
ElementUI.Dialog.props.closeOnClickModal.default=false;

Vue.use(AVUE, {
  locale: zhLocale,
  size: 'small',
  menuType: 'text'
})

Vue.use(permission)
// 注册全局容器
Vue.component('basicContainer', basicContainer)
Vue.component('DictTag', DictTag)
Vue.component('v-chart',VueEcharts)
// 全局组件挂载
Vue.component('PageMain', PageMain)
Vue.component('PageLr', PageLr)
Vue.component('DeleteData', DeleteData)
Vue.component('MyDateRange', MyDateRange)
Vue.component('MyEcharts', MyEcharts)
Vue.component('MyUpload', MyUpload)
Vue.component('FormItem', FormItem)
Vue.component('FormRender', FormRender)

// 加载相关url地址
Object.keys(urls).forEach(key => {
  Vue.prototype[key] = urls[key]
})

// 加载过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// 动态加载阿里云字体库
iconfontUrl.forEach(ele => {
  loadStyle(ele)
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
